<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>

<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js"></script>

<fmt:message key="nome.tamanho" var="nome_tamanho" />
<fmt:message key="sobrenome.tamanho" var="sobrenome_tamanho" />
<fmt:message key="login.tamanho" var="login_tamanho" />
<fmt:message key="senha.tamanho" var="senha_tamanho" />
<fmt:message key="email.tamanho" var="email_tamanho" />

<script type="text/javascript">

$("#${param.formName}").validate({
	rules: {
		"usuario.nome": {
			required: true,
			minlength: 3,
			maxlength: 12
		},
		"usuario.sobrenome": {
			required: true,
			minlength: 3,
			maxlength: 15
		},
		"usuario.login": {
			required: true,
			minlength: 4,
			maxlength: 20
		},
		"usuario.passw": {
			required: true,
			minlength: 3,
			maxlength: 12
		},
		"usuario.email": {
			required: true,
			minlength: 8,
			maxlength: 30
		}
	},
	
	messages: {
		"usuario.nome": {
			required: "${nome_tamanho}",
			minlength: "${nome_tamanho}",
			maxlength: "${nome_tamanho}"
		},
		"usuario.sobrenome": {
			required: "${sobrenome_tamanho}",
			minlength: "${sobrenome_tamanho}",
			maxlength: "${sobrenome_tamanho}"
		},
		"usuario.login": {
			required: "${login_tamanho}",
			minlength: "${login_tamanho}",
			maxlength: "${login_tamanho}"
		},
		"usuario.passw": {
			required: "${senha_tamanho}",
			minlength: "${senha_tamanho}",
			maxlength: "${senha_tamanho}"
		},
		"usuario.email": {
			required: "${email_tamanho}",
			minlength: "${email_tamanho}",
			maxlength: "${email_tamanho}"
		}
	},

	highlight: function (element) {
		$(element).addClass('error').removeClass('error');
    },
	
	success: function (element) {
		$(element).removeClass('error');
    }
});

</script>